<template>
  <div :class="`item ${ isMe?'rowAgin':'row1'}`">
    <img :src="from.avtar.url" alt="">
    <div class="talkItem">
      {{content}}
    </div>
  </div>
</template>
<script>
  import { defaultImage } from "../../assets";
  export default {
    props: {
      from: {
        type: Object,
        default: { avtar: { url: defaultImage } }
      },
      isMe: {
        type: Boolean,
        default: false
      },
      content: {
        type: String,
        default: ""
      }
    },
    created() {
    },
    data() {
      return { defaultImage };
    }
  };
</script>
<style lang="less" scoped>
  .item {
    box-sizing: border-box;
    display: flex;
    padding: 5px 15px;

    .talkItem {
      margin-top: 20px;
      border: 1px solid #eee;
      background: #eee;
      width: 80%;
      border-radius: 0 10px 10px 10px;
      margin-left: 20px;
      padding: 5px;
      position: relative;

      &::before {
        content: "";
        width: 0;
        height: 0;
        left: -20px;
        top: -1px;
        position: absolute;
        border-top: 0px solid transparent;
        border-right: 20px solid #eee;
        border-bottom: 20px solid transparent;
      }
    }

    img {
      width: 50px;
      height: 50px;
      border-radius: 100%;
      border: 2px solid #eee;
    }

    &.rowAgin {
      flex-direction: row-reverse;

      .talkItem {
        margin-top: 20px;
        position: relative;
        border-radius: 10px 0 10px 10px;
        margin-left: 0px;
        margin-right: 20px;

        &::before {
          content: none;
        }

        &::after {
          content: "";
          width: 0;
          height: 0;
          right: -20px;
          top: -1px;
          position: absolute;
          border-top: 0px solid transparent;
          border-left: 20px solid #eee;
          border-bottom: 20px solid transparent;
        }
      }
    }
  }
</style>